The BAAN application exposes
just one object, which is the application object.
In Visual Basic this object can be created with: Set Baan4Obj = CreateObject("Baan4.Application") This will start BAAN, with the BW user interface, in an invisible way, i.e. only the Option Dialog icon will be displayed. |
|||||||||||||||
OLE Automation objects,
Baan4Obj is one, can have methods and properties.
- A method is a function that can be called to perform a certain action. - A property is an attribute that has a value. Property values can be set and/or retrieved |
|||||||||||||||
The BAAN
application object has the following methods:
- ParseExecFunction "dllname", "functioncall" - Quit The BAAN application object has the following properties:
These methods and properties allow Visual Basic programmers to call any function in any dll. For example:
To
end an automation session the following example shows how to quit the BAAN
application.
|
|||||||||||||||
3 Limitations
Following are some limitations
when using the OLE Automation interface:
|
|||||||||||||||
The following simple example will
fill an MS-Excel spreadsheet with the names of all BAAN users.
To implement this, we have to do
two things:
DLL function example The DLL below (called demodll) contains two functions to retrieve the names of the users from the database. One function to initiate the query and get the first name and another function to get the next name. When the last record has been returned an empty string will be returned.
table tttaad200
function extern string get_first_user()
switch.to.company(0)
if e = 0
return( user )
function extern string get_next_user()
if e = 0
return( user )
|
|||||||||||||||
Visual Basic example
MS-Excel contains Visual
Basic for Applications (VBA) that allows for scripting to control the Excel
application, but also to control other applications through OLE Automation.
The following is the Visual Basic source that will call the DLL functions
mentioned above and display the results in a spreadsheet. The subroutine
GetBaan4Users is an MS-Excel macro which can be invoked through user interface
controls on the spreadsheet (buttons or menus).
Sub GetBaan4Users()
' run Baan4
On Error GoTo Baan4AutomationError
' get first user
Row = 1
' get next user
' exit Baan4
' error handling
Baan4AutomationError:
End Sub |
|||||||||||||||
Example: Using Baan IV SQL
The following example will
fill an MS-Excel spreadsheet using BAAN SQL. To implement this a DLL, named
ottdllsql_query, has been developed to parse and execute the query. To
receive more information about this library, enter the following command:
*> bic_info6.1 -eu ottdllsql_query [SHbic_info6.1 -eu ottdllsql_query]
|